
#import "JZTabBarViewController.h"
#import "JZNavigationController.h"
#import "JZBBookViewController.h"
#import "JZBMineViewController.h"
#import "JZBDetailViewController.h"

@interface JZTabBarViewController ()<UITabBarControllerDelegate>

@end

@implementation JZTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    [self setupColor];
    [self setupViewController];
    // Do any additional setup after loading the view.
}

- (void)setupColor{
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.tabBar.tintColor = [UIColor colorWithHexString:@"#333333"];
    self.tabBar.unselectedItemTintColor = [UIColor colorWithHexString:@"#999999"];
    self.tabBar.backgroundImage = [UIImage imageWithColor:[UIColor whiteColor]];
    self.tabBar.backgroundColor = [UIColor  whiteColor];
}

- (void)setupViewController{
    JZBBookViewController *vc1 = [[JZBBookViewController alloc] init];
    JZBDetailViewController *vc2 = [[JZBDetailViewController alloc] init];
    JZBMineViewController *vc3 = [[JZBMineViewController alloc] init];
    
    NSArray *controllerArray = @[vc1,vc2,vc3];
    NSArray *titles = @[@"账本",@"明细",@"我的"];
    NSArray *imgs = @[@"记账本_未选中",@"明细_未选中",@"我的_未选中"];
    NSArray *selectimgs = @[@"记账本",@"明细",@"我的"];
    for (int i = 0; i < controllerArray.count; i++) {
        UIViewController *vc = controllerArray[i];
        vc.tabBarItem = [[UITabBarItem alloc] init];
        vc.tabBarItem.title = LS(titles[i]);
        vc.tabBarItem.image = [[UIImage imageNamed:imgs[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectimgs[i]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        JZNavigationController *nav = [[JZNavigationController alloc] initWithRootViewController:vc];
        [self addChildViewController:nav];
    }
}

#pragma mark - UITabBarControllerDelegate
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
    return YES;
}
@end
